import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import {menus} from '@/utils/menus.js'

Vue.use(VueRouter)

//   const routes = [
//   {
//     path: '/',
//     name: 'Home',
//     component: Home
//   },
//   {
//     path: '/about',
//     name: 'About',
//     // route level code-splitting
//     // this generates a separate chunk (about.[hash].js) for this route
//     // which is lazy-loaded when the route is visited.
//     component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
//   }
// ]

//创建路由信息对象
const routes = [
  { path: '/', redirect: '/login' },
  {path: '/login',name: 'Login',component: () => import('@/views/Login.vue')},
  {
    path:'/index',
    name:"Index",
    component:()=>import('@/views/Index.vue'),
    redirect:'/index/home',
    children:[
      ...menus
    ]
  
  },
  { path: '/404', name: 'notFound', component: () => import('@/views/errorPage/404.vue') },
  { path: '*', redirect: '/404' }
]


const router = new VueRouter({
  mode: 'hash',
  base: '',
  routes
})

export default router
